#include <vector>
#include <map>

using namespace std;

class Solution {
public:
    int removeElement(vector<int>& nums, int val) {
        int cnt_idx = 0;
        for(int i = 0; i < nums.size(); i++)
        {
            if(nums[i] != val)
            {
                if(i > cnt_idx)
                    nums[cnt_idx] = nums[i];
                cnt_idx++;
            }
        }

        return cnt_idx;
    }
};